﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Web.Admin
{
    public partial class Link_Add : BaseCode.BaseAdmin
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                HideContorl();
            }
        }

        /// <summary>
        /// 初始化错误提示区域于控件默认值
        /// </summary>
        private void HideContorl()
        {
            this.hideone.Visible = false;
            this.hidetwo.Visible = false;
            this.hidethree.Visible = false;
            this.checkbox1.Checked = true;
            this.radio1.Checked = true;
        }
        public void AddLink(object sender, EventArgs e)
        {
            int statr=0;
            string target="_parent";
            if(this.radio1.Checked==true)
            {
                statr=1;
            }
            if(this.checkbox1.Checked==true)
            {
                target="_blank";
            }
            Model.Model_Link link = new Model.Model_Link
            {
                addtime = DateTime.Now,
                updatetime = DateTime.Now,
                name = this.nameinput.Value,
                title = this.titleinput.Value,
                url = this.mediuminput.Value,
                remark = this.textarea.Value,
                target = target,
                state = statr
            };

            int i = BLL.BLL_Link.Add(link);
            if (i > 0)
            {
                Common.RunScript.Alert(this, "添加成功");
            }
            else
            {
                Common.RunScript.Alert(this, "添加失败");
            }
        }

    }
}